home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / where12.zip / WHERE.DOC < prev   
Text File  |  1993-10-21  |  2KB  |  62 lines

  1.  
  2.  
  3. WHERE (v1.2) - Where is a file in the PATH or other environment variable
  4. Copyright 1989-1993 by David G. Thomas
  5.  
  6. You may use this program as you please, and may distribute it
  7. to your friends.  You may NOT alter the program, and you MUST
  8. include this file when you pass it on.
  9.  
  10. This program saves typing as it will "find" a file for you.  The E.BAT
  11. in our example at the bottom of this file edits a file by name (not path).
  12. For example, to look at the standard C include file, "MALLOC.H", simply
  13. type "E MALLOC", and it will edit "H:\LANG\MSC51\INCLUDE\MALLOC.H".
  14.  
  15. USAGE: 
  16.    WHERE name              - Look in PATH for name.bat name.com name.exe
  17.    WHERE env_var name      - Look in env_var for name
  18.    WHERE env_var name .suf - Look in env_var for name.suf
  19.    WHERE dir;dir name .suf - Look in the dirs for name.suf
  20.  
  21. Options (must be first arg)
  22.    -Env     - The results are placed in the RET environment variable
  23.    -Full    - Return the fully qualified path
  24.    -Name    - Print name only
  25.    -Quiet   - Do not print File Not Found message
  26.    -Subst   - Return the fully qualified path, chasing SUBST disk
  27.    -Upper   - Results are upper case
  28.  
  29. Errorlevel is set to the number of files found.
  30.  
  31.  
  32. E.BAT
  33. ------------------------
  34. @echo off
  35.  
  36. :*  This batch file will edit a file, given only the file name.
  37. :*  If necessary, it will search the INCLUDE and PATH environment 
  38. :*  paths for the file.  Also, a special path named E_PATH is used.    
  39.  
  40.  
  41.    if exist %1 goto use_args
  42.  
  43.    set RET=
  44.  
  45.    where -q -e E_PATH  %1 .c .h .bat
  46.    if errorlevel 1 goto frompath
  47.  
  48.    where -q -e INCLUDE %1 .h
  49.    if errorlevel 1 goto frompath
  50.  
  51.    where -q -e PATH    %1 .bat .doc .txt
  52.    if errorlevel 1 goto frompath
  53.  
  54. :use_args
  55.    edit %1 %2 %3 %4 %5 %6 %7
  56.    goto end
  57.  
  58. :frompath
  59.    edit %ret%
  60.  
  61. :end
  62.